#ifndef __SC_Touch_H__
#define __SC_Touch_H__

#include "Arduino.h"
#include "Wire.h"
#include "map"

// SC05B的设备地址
#define SC05B_ADDRESS 0x41
// SC05B默认读取按键值的寄存器地址
#define KEY_VALUE_REGISTER 0x08

typedef void (*CallbackFunction)(void);
typedef void (*ParameterizedCallbackFunction)(void *);

class Button
{
private:
    int key;

public:
    Button(int key);
    ~Button();

    void onClick(CallbackFunction callback);
    void onClick(ParameterizedCallbackFunction callback, void *parameter);

    void onLongPress(CallbackFunction callback);
    void onLongPress(ParameterizedCallbackFunction callback, void *parameter);

    void onDoubleClick(CallbackFunction callback);
    void onDoubleClick(ParameterizedCallbackFunction callback, void *parameter);
};

class SCTouch
{
private:
    int pin;
    std::map<int, Button> keyButtons;

public:
    SCTouch(int pin);
    ~SCTouch();

    Button getButton(int key);
    void tick();
};

#endif